package com.sfeir.poc.portal.gui.client.dnd;

import com.allen_sauer.gwt.dnd.client.drop.IndexedDropController;
import com.google.gwt.user.client.ui.DecoratorPanel;
import com.google.gwt.user.client.ui.FocusPanel;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Panel;
import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;

/**
 * 
 * WindowPanel in which widgets are added 
 *
 */
public class WindowPanel extends FocusPanel {

	private Widget contentOrScrollPanelWidget;

	private final FocusPanel headerContainer;

	public WindowPanel(IndexedDropController windowController, Widget headerWidget,
			Widget contentWidget, boolean wrapContentInScrollPanel) {
		this.setWidth("100%");
		this.addStyleName("widget-container");

		contentWidget.addStyleName("content-widget");
		contentWidget.setWidth("100%");
		contentOrScrollPanelWidget = wrapContentInScrollPanel ? new ScrollPanel(contentWidget)
		: contentWidget;

		headerContainer = new FocusPanel();
		headerContainer.setWidth("100%");
		headerContainer.addStyleName("widget-header");
		Panel headerPanel = new HorizontalPanel();
		headerPanel.setSize("100%", "100%");
		headerWidget.setHeight("20px");
		headerPanel.add(headerWidget);
		headerPanel.addStyleName("header-widget");
		headerContainer.add(headerPanel);

		VerticalPanel verticalPanel = new VerticalPanel();
		verticalPanel.setWidth("100%");
		verticalPanel.addStyleName("widget-vertical-panel");
		verticalPanel.add(headerContainer);
		verticalPanel.add(contentOrScrollPanelWidget);

		DecoratorPanel panel = new DecoratorPanel();
		panel.setWidth("100%");
		panel.add(verticalPanel);

		add(panel);
	}
}
